package com.systop.asset.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.systop.asset.entity.RestResponse;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.systop.asset.entity.Department;
import com.systop.asset.service.IDepartmentService;

/**
 * 组织架构部门信息Controller
 * 
 * @author lsp
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/department")
public class DepartmentController
{
    @Autowired
    private IDepartmentService departmentService;

    /**
     * 查询组织架构部门信息列表
     */
    @GetMapping("/list")
    public RestResponse list(Department department)
    {
        List<Department> list = departmentService.selectDepartmentList(department);
        return RestResponse.success(list);
    }

    @GetMapping("/tree")
    public RestResponse listTree(Department department)
    {
        List<Department> list = departmentService.selectDepartmentTree(department);
        return RestResponse.success(list);
    }


    /**
     * 获取组织架构部门信息详细信息
     */
    @GetMapping(value = "/{id}")
    public RestResponse getInfo(@PathVariable("id") Long id)
    {
        return RestResponse.success(departmentService.selectDepartmentById(id));
    }

    /**
     * 新增组织架构部门信息
     */
    @PostMapping
    public RestResponse add(@RequestBody Department department)
    {
        return RestResponse.success(departmentService.insertDepartment(department));
    }

    /**
     * 修改组织架构部门信息
     */
    @PutMapping
    public RestResponse edit(@RequestBody Department department)
    {
        return RestResponse.success(departmentService.updateDepartment(department));
    }

    /**
     * 删除组织架构部门信息
     */
	@DeleteMapping("/{ids}")
    public RestResponse remove(@PathVariable Long[] ids)
    {
        return RestResponse.success(departmentService.deleteDepartmentByIds(ids));
    }




}
